home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 2000 February
/
Macworld (2000-02).dmg
/
Games World
/
Hot demos!
/
Starbound II
/
AI agents
/
Gypsum 1.00
/
Gypsum 1.00.rsrc
/
ss$t_148
< prev
Wrap
Text File
|
1999-10-30
|
4KB
|
152 lines
situation planet_production
vars
p : planet;
i : integer;
st : integer;
success : boolean;
hex : integer;
struct : structure;
function Find_empty_hex(p : planet) : integer;
vars
target : integer;
begin
target := Random(127);
while (Hex_structure(p, target) <> nil) do
target := Random(127);
return(target);
end;
// Main function
begin
p := This_planet();
// First set the tech spending levels
Set_weapon_spending(p, w_spending);
Set_shield_spending(p, s_spending);
Set_move_spending(p, m_spending);
Set_detect_spending(p, d_spending);
Set_develop_spending(p, 50);
// Now see if we want to build a ship
if ((Planet_weapon(p) > tech_min) and
(Planet_shield(p) > tech_min) and
(Planet_move(p) > tech_min) and
(Planet_detect(p) > tech_min)) then
Set_ship_spending(p, 100);
else
Set_ship_spending(p, 0);
// If there are more then two ships, then send out a squad
if (Orbit_num_ships(p) >= fleet_size+1) then
begin
i := 1; // Don't want to send starbase
while (i < Orbit_num_ships(p)) do
begin
success := Orbit_depart(p, i, true);
i := i + 1;
end;
end;
// If a new ship has been built then set the ship type
if (New_ship(p)) then
begin
i := 0;
while (Can_build_ship_type(p, i)) do
i := i + 1;
if (i > 0) then
begin
st := Random(i);
success := Construct_ship_type(p, st);
end;
// Now set the troops to fill it
i := 0;
while (i < 8) do
begin
success := Stardock_set_manifest(p, i, 0);
i := i + 1;
end;
// Now refill the ship, try one of each
// repeat until the lowest troop fails
success := true;
while (success) do
begin
success := false;
i := 7;
while (i > 0) do
begin
if (Can_build_troop(p, i)) then
success := success or Stardock_set_manifest(p, i, Stardock_get_manifest(p, i)+1);
i := i - 1;
end;
end;
end;
// If there are 0 projects, then build a barracks or space port.
if (Num_projects(p) = 0) then
begin
if (Num_structures(p, 10) < 6) then // space port
begin
// Select a random hex
hex := Find_empty_hex(p);
success := Create_structure(p, hex, 10);
end;
if (Num_structures(p, 2) < 6) then // barracks
begin
// Select a random hex
hex := Find_empty_hex(p);
success := Create_structure(p, hex, 2);
end;
end;
// See if we need to reorganize the barracks
if ((New_structure(p)) or (New_troop(p))) then
begin
struct := First_structure(p);
while (struct <> nil) do
begin
// if ((Structure_has(My_race(), Structure_type(p,struct),106)) and (Structure_left(p, struct) = 0)) then
if (Structure_has(My_race(), Structure_type(p,struct), 106)) then
begin
// Clear the old troops in the barracks
i := 1;
while (i < 8) do
begin
success := Set_barracks(p, struct, i, 0);
i := i + 1;
end;
// Now refill the barracks, try one of each
// repeat until the lowest troop fails
success := true;
while (success) do
begin
success := false;
i := 7;
while (i > 0) do
begin
if (Can_build_troop(p, i)) then
success := success or Set_barracks(p, struct, i, Get_barracks(p, struct, i)+1);
i := i - 1;
end;
end;
end;
struct := Next_structure(p, struct);
end;
end;
end;